package fpzhan.plane.program.connect;

import com.alibaba.fastjson.JSONObject;
import fpzhan.plane.program.constant.ComposeType;
import fpzhan.plane.program.compose.CodeBlockCompose;
import fpzhan.plane.program.compose.ComposeContent;
import fpzhan.plane.program.function.CodeBlockFunction;
import fpzhan.plane.program.proxy.CodeBlockProxy;
import fpzhan.plane.program.struct.CodeBlockStruct;

import java.util.List;

public class ChainCodeBlockCompose extends CodeBlockCompose {

    private CodeBlockFunction codeBlock;

    public ChainCodeBlockCompose(CodeBlockFunction codeBlock) {
        this.codeBlock = codeBlock;
        this.setComposeType(ComposeType.FLOW);
    }

    protected ChainCodeBlockCompose(CodeBlockFunction codeBlock,String composeType) {
        this.codeBlock = codeBlock;
        this.setComposeType(composeType);
    }



//    public ChainCodeBlockCompose(ComposeContext composeContext, CodeBlockFunction codeBlock) {
//        super(composeContext);
//        this.codeBlock = codeBlock;
//        this.setComposeType(ComposeType.FLOW);
//    }


    @Override
    public CodeBlockFunction compose(List<CodeBlockProxy> proxys, JSONObject json,
                                     CodeBlockStruct struct, JSONObject structJson,
                                     ComposeContent composeContent) throws Exception {
        return super.compose(proxys, json, struct, structJson, composeContent, this.codeBlock);
    }

    public boolean isEmpty(){
        if (codeBlock==null){
            return true;
        }else {
            return false;
        }
    }

}
